<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>include page</title>
</head>
<body>
<div th:fragment="common_update_password">
    <div class='row-fluid' id='content-wrapper'>
        <div class='span12'>
            <div class='page-header'>
                <h1 class='pull-left'> <i class='icon-dashboard'></i> <span>修改密码</span> </h1>
            </div>
        </div>
        <form class='form' style='margin-left: 0;' />
        <div class='modal-body'>
            <div class='control-group'>
                <label class='control-label'>原密码</label>
                <div class='controls'>
                    <input class='span3' id='origin-pwd' name="originPwd" placeholder='原密码' type='password'/>
                </div>
            </div>
            <div class='control-group'>
                <label class='control-label'>新密码</label>
                <div class='controls'>
                    <input class='span3' id='new-pwd' name="newPwd" placeholder='新密码' type='password' />
                </div>
            </div>
            <div class='control-group'>
                <label class='control-label'>密码确认</label>
                <div class='controls'>
                    <input class='span3' id='affirm-pwd' name="affirmPwd" placeholder='再次输入新密码' type='password' />
                </div>
            </div>
            <div class='control-group'>
                <div class='controls'>
                    <a class='btn btn-success btn-mini' href='#' th:onclick="modifyPwd([[${session.loginName}]]);">提交</a>
                </div>
            </div>
        </div>
        </form>
    </div>
<!--    <div class='row-fluid'>
        <form class='form' style='margin-left: 0;' />
        <div class='modal-body'>
            <div class='control-group'>
                <label class='control-label'>原密码</label>
                <div class='controls'>
                    <input class='span3' id='origin-pwd' name="originPwd" placeholder='原密码' type='password'/>
                </div>
            </div>
            <div class='control-group'>
                <label class='control-label'>新密码</label>
                <div class='controls'>
                    <input class='span3' id='new-pwd' name="newPwd" placeholder='新密码' type='password' />
                </div>
            </div>
            <div class='control-group'>
                <label class='control-label'>密码确认</label>
                <div class='controls'>
                    <input class='span3' id='affirm-pwd' name="affirmPwd" placeholder='再次输入新密码' type='password' />
                </div>
            </div>
            <div class='control-group'>
                <div class='controls'>
                    <a class='btn btn-success btn-mini' href='#' th:onclick="modifyPwd([[${session.loginName}]]);">提交</a>
                </div>
            </div>
        </div>
        </form>
    </div>-->
    <script type="text/javascript">
        function modifyPwd(loginName) {
            var originPwd = $("#origin-pwd").val(),
                newPwd = $("#new-pwd").val(),
                affirmPwd = $("#affirm-pwd").val();
            if (newPwd != affirmPwd){
                alert("两次密码输入不同！");
                return;
            }
            $.post("/user/modify_pwd",{"originPwd":originPwd,"newPwd":newPwd,"loginName":loginName},
                function(data){
                    if(data == "SUCCESS"){
                        alert("修改密码成功！");
                    }else{
                        alert("修改密码失败！");
                    }
                });
        }
    </script>
</div>
</body>
</html>